<?php

// 获取我的代理分页列表
// GET member.agents
// http://sg.io/api?member.agents

namespace app\api\resource\member;
use app\api\lib\Page;
use think\facade\Session;

class Agents
{
    // 方法
    public $_method = ['GET'];
    // 前置
    public $_pre    = ['member'];
    // 描述
    public $_description = '获取我的代理分页列表';
    // 参数
    public $_param  = [];

    public function run(&$request)
    {
		$page   = $request->get('page/d',1);
		$show   = $request->get('show/d',10);
		
		$member = Session::get('member');
		
		$table   = 'member';
		$where[] = [ 'pid','=',$member['id'] ];
		$order   = 'create_time DESC';
		$pagelist = Page::run($table,$where,$order,$page,$show);
		
		if ( !empty($pagelist['list']) ) {
			foreach($pagelist['list'] as $key => $val) unset($pagelist['list'][$key]['password'],$pagelist['list'][$key]['ext']);
		}
		
		return [200,$pagelist];
    }
}
